package com.voicechat.firstmet.adapter;


import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.View;
import android.widget.TextView;

import com.voicechat.firstmet.R;
import com.voicechat.firstmet.base.BaseAdapter;
import com.voicechat.firstmet.bean.GifBean;
import com.voicechat.firstmet.utils.Utils;

import java.text.ParseException;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * @ProjectName: FirstMet
 * @Package: com.voicechat.firstmet.adapter
 * @ClassName: IncomeRecordAdapter
 * @Description: 我的礼物记录adapter
 * @Author: ljp
 * @CreateDate: 2018/10/11 10:01
 * @Version: 1.0
 */
public class MyGifRecordAdapter extends BaseAdapter<GifBean.PageBean.ListBean> {
    private List<GifBean.PageBean.ListBean> tlist;
    /**
     * @param context activity_imessage
     * @param tlist   集合
     * @param mLayout 主布局
     */
    public MyGifRecordAdapter(Context context, List<GifBean.PageBean.ListBean> tlist, int mLayout) {
        super(context, tlist, mLayout);
        this.tlist = tlist;
    }

    @Override
    protected RecyclerView.ViewHolder getHeaderViewHolder(View view) {
        return null;
    }

    @Override
    protected RecyclerView.ViewHolder getItemViewHolder(View view) {
        return new ViewHolder(view);
    }

    @Override
    protected RecyclerView.ViewHolder getFooterViewHolder(View view) {
        return null;
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, int position) {
        if(viewHolder instanceof ViewHolder){
            GifBean.PageBean.ListBean listBean = tlist.get(position);
            ((ViewHolder) viewHolder).tvGet.setText(listBean.getGold()+"");
            String format = "yyyy-MM-dd HH:mm";
            try {
                String s = Utils.dateToString(Utils.stringToDate(listBean.getCreateDate(), format), format);
                ((ViewHolder) viewHolder).tvGetData.setText(s);
            } catch (ParseException e) {
                e.printStackTrace();
            }
           // ((ViewHolder) viewHolder).tvGetName.setText(listBean.getName()+"×"+listBean.getNumber());
            ((ViewHolder) viewHolder).tvUsercp.setText(listBean.getRemarks());
            Log.i("onBindViewHolder", "onBindViewHolder: ----------"+listBean.toString());
        }

    }

    class ViewHolder extends BaseViewHolder{
        @BindView(R.id.tv_get_name)
        TextView tvGetName;
        @BindView(R.id.tv_get_data)
        TextView tvGetData;
        @BindView(R.id.tv_get)
        TextView tvGet;
        @BindView(R.id.tv_usercp)
        TextView tvUsercp;
        public ViewHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this,itemView);
        }
    }
}
